from django.urls import path, include
from rest_framework.routers import DefaultRouter
from . import views

# 创建路由器
router = DefaultRouter()

# 注册视图集
router.register(r'auth', views.AdminAuthViewSet, basename='admin-auth')
router.register(r'dashboard', views.AdminDashboardViewSet, basename='admin-dashboard')
router.register(r'admin-users', views.AdminUserViewSet, basename='admin-users')
router.register(r'roles', views.RoleViewSet, basename='roles')
router.register(r'permissions', views.PermissionViewSet, basename='permissions')
router.register(r'user-roles', views.UserRoleViewSet, basename='user-roles')
router.register(r'audit-logs', views.AuditLogViewSet, basename='audit-logs')
router.register(r'system-config', views.SystemConfigViewSet, basename='system-config')
router.register(r'user-management', views.UserManagementViewSet, basename='user-management')

# URL模式
urlpatterns = [
    path('', include(router.urls)),
]

# 为了方便访问，也可以添加一些直接的URL模式
urlpatterns += [
    # 管理员认证相关
    path('login/', views.AdminAuthViewSet.as_view({'post': 'login'}), name='admin-login'),
    path('logout/', views.AdminAuthViewSet.as_view({'post': 'logout'}), name='admin-logout'),
    path('profile/', views.AdminAuthViewSet.as_view({'get': 'profile'}), name='admin-profile'),
    
    # 仪表板相关
    path('dashboard/stats/', views.AdminDashboardViewSet.as_view({'get': 'stats'}), name='admin-dashboard-stats'),
    path('dashboard/activities/', views.AdminDashboardViewSet.as_view({'get': 'recent_activities'}), name='admin-dashboard-activities'),
]